package com.sanweibook.jhook.web.sys;

import com.sanweibook.jhook.biz.sys.SysUserService;
import com.sanweibook.jhook.common.result.Result;
import com.sanweibook.jhook.dal.model.sys.SysUser;
import com.sanweibook.jhook.shiro.hash.UserSimpleHash;
import com.sanweibook.jhook.web.util.UsernamePasswordTokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by twg on 2017/4/15.
 */
@Controller
@RequestMapping("/admin/sys/user")
public class SysUserController {
    @Autowired
    private SysUserService sysUserService;


    public String list(){
        return "";
    }

    @RequestMapping("/save")
    public Result<String> save(){
        SysUser sysUser = new SysUser();
        sysUser.setUserName("jhook");
        UserSimpleHash simpleHash = UsernamePasswordTokenUtils.doPassword("jhook","jhook_0575");
        sysUser.setUserPassword(simpleHash.toHex());
        sysUser.setSalt(simpleHash.getRandomSalt());
        sysUser.setStatus(1);
        sysUser.setUserLevel(3);
        sysUser.setCreator(0L);
        sysUser.setModifier(0L);
        sysUserService.save(sysUser);
        return Result.returnSuccessResult("");
    }


}
